package com.sync.data.ievent.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.sync.data.base.BaseEntity;
import com.sync.data.common.annotation.FieldProps;
import com.sync.data.common.annotation.FieldType;
import com.sync.data.common.annotation.RenderType;
import com.sync.data.common.obj.annoation.ObjectPrefix;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * 讲者对象
 *
 * @author liquanchang
 */
@Getter
@Setter
@Entity
@ObjectPrefix("iaii")
@Table(name = "mt_speaker_schema")
public class MtSpeakerSchema extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @FieldProps(type = FieldType.STRING, label = "名称")
    private String name;

    @FieldProps(type = FieldType.STRING, label = "客户ID")
    private String accId;

    @FieldProps(type = FieldType.STRING, label = "讲者编号")
    private String hcpId;
    @FieldProps(type = FieldType.STRING, label = "讲者编号--sap需要处理后的字段，此字段无法反向恢复成hcpId")
    // hcpReq = REPLACE(REPLACE(REPLACE(hcp_id, 'OBU_DOC_D', 'OBD'), 'OBU_DOC_', 'OB'), 'NCN', '')
    private String hcpReq;

    @FieldProps(type = FieldType.DICT, label = "证件类型", renderType = RenderType.Select)
    private String idType;

    @FieldProps(type = FieldType.STRING, label = "证件号码")
    private String idNum;


    @FieldProps(type = FieldType.STRING, label = "手机号码")
    private String mobile;

    @FieldProps(type = FieldType.STRING, label = "邮箱")
    private String email;

    @FieldProps(type = FieldType.SHARE_DICT, label = "协议信息", renderType = RenderType.Select, shareDict = "boolean")
    private String protocol = "0";

    @FieldProps(type = FieldType.DICT, label = "接受信息渠道", renderType = RenderType.MultipleSelect)
    private String channel;


    @FieldProps(type = FieldType.STRING, label = "银行")
    private String bankName;

    @FieldProps(type = FieldType.STRING, label = "开户行")
    private String openingBank;


    @FieldProps(type = FieldType.STRING, label = "账户名")
    private String accBankUserName;

    @FieldProps(type = FieldType.STRING, label = "银行卡账号")
    private String bankAccount;

    @FieldProps(type = FieldType.STRING)
    private String bankSpeakerStatus;

    @FieldProps(type = FieldType.STRING)
    private String bankSpeakerLibrary;

    @FieldProps(type = FieldType.STRING)
    private String bankPartnerType;

    @FieldProps(type = FieldType.STRING, label = "sap code")
    private String vendorCode;

    @FieldProps(type = FieldType.DICT, label = "讲者类型", renderType = RenderType.Select)
    private String typeId;


    @FieldProps(type = FieldType.DICT, label = "讲者级别", renderType = RenderType.Select)
    private String gradeId;

    /**
     * 启用状态 1 启用 0 禁用
     */
    /**
     * 是否有效
     */
    @FieldProps(type = FieldType.SHARE_DICT, label = "是否生效", renderType = RenderType.Select, shareDict = "boolean")
    private Integer active;

    @FieldProps(type = FieldType.SHARE_DICT, label = "是否锁定", renderType = RenderType.Select, shareDict = "boolean")
    private Integer lockOut;

    @JsonIgnoreProperties(value = {"speakerSchemas"})
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "accId", referencedColumnName = "id", insertable = false, updatable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    private Hcp hcp;


    @FieldProps(type = FieldType.DATE, label = "Centris讲者最后使用时间", renderType = RenderType.DatePicker)
    private Date migrationLastUseDate;

    @FieldProps(type = FieldType.STRING, label = "Bank key")
    private String bankKey;


    /**
     * 锁定原因类型
     */
    @Transient
    @FieldProps(type = FieldType.DICT, label = "锁定原因类型", renderType = RenderType.Select)
    private String reasonType;

    @FieldProps(type = FieldType.STRING ,label = "SWIFT代码" )
    private String swiftCode;

    @FieldProps(type = FieldType.STRING ,label = "IBAN" )
    private String iban ;

    @FieldProps(type = FieldType.CASCADE,label = "开户省份)",renderType = RenderType.Cascader,cascadeLevel = 1,cascadeObject = "bankAddress",notNull = false)
    private String bankProvince;


    @FieldProps(type = FieldType.CASCADE,label = "开户城市",renderType = RenderType.Cascader,cascadeLevel = 2,cascadeObject = "bankAddress",notNull = false)
    private String bankCity;


    @FieldProps(type = FieldType.STRING ,label = "海外银行" )
    private String foreignBank;

    @FieldProps(type = FieldType.STRING ,label = "海外银行地址" )
    private String foreignBankAddress;
}
